package com.tarena.lbs.basic.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.basic.pojo.param.TagTypeParam;
import com.tarena.lbs.basic.pojo.vo.TagTypeVO;
import com.tarena.lbs.basic.service.TagService;
import com.tarena.lbs.basic.service.TagTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "标签分类数据管理")
@RestController
public class TagTypeController {
    @Autowired
    private TagTypeService tagTypeService;

    @Operation(summary = "新增标签分类")
    @PostMapping("/admin/basic/tagType/addTagType")
    public Result<Void> sageType(@RequestBody TagTypeParam param){
        tagTypeService.saveTagType(param);
        return Result.success();//code=0 success=true
    }
    @Operation(summary = "修改标签分类")
    @PostMapping("/admin/basic/tagType/updateTagType")
    public Result<Void> updateType(@RequestBody TagTypeParam param){
        tagTypeService.updateType(param);
        return Result.success();//code=0 success=true
    }


    @Operation(summary = "展示分类标签")
    @GetMapping("/admin/basic/tagType/tagTypeList")
    public Result<List<TagTypeVO>> tagTypeList(){
        List<TagTypeVO> listVO = tagTypeService.tagTypeList();
        return new Result<>(listVO);//code=0 success=true
    }

    @Operation(summary = "查询所有分类信息")
    @GetMapping("/admin/basic/tagType/tagTypeAll")
    public Result<List<TagTypeVO>> getTagTypeAll(){
        List<TagTypeVO> vos = tagTypeService.getTagTypeAll();
        return new Result<>(vos);
    }

    @Operation(summary = "标签id查询父类型")
    @GetMapping("/admin/basic/tagType/getTageType/{id}")
    public Result<TagTypeVO> getTagType(@PathVariable("id") Integer id){
        TagTypeVO vo = tagTypeService.getTagType(id);
        return new Result<>(vo);
    }
}
